package com.salt.modules.sys.feign;

import com.salt.common.constant.Common;
import com.salt.modules.sys.entity.Role;
import com.salt.modules.sys.service.RoleService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;
import java.util.Set;

/**
 * @Description
 * @Author salt
 * @Date 2021-04-08
 * @Version 1.0.1
 */
@RestController
@RequestMapping(Common.Service.SALT_ADMIN_ROLE_URL_PREFIX)
public class RoleFeignController {

    @Autowired
    private RoleService roleService;

    @PostMapping("findAllList")
    public List<Role> findAllList(Role role) {
        return roleService.findAllList(role);
    }

    @PostMapping("get")
    public Role get(@RequestParam("id")String id) {
        return roleService.get(id);
    }

    /**
     * 根据ID的集合获取角色
     * @param ids
     * @return
     */
    @PostMapping("queryByIds")
    public List<Role> queryByIds(@RequestParam("ids") List<String> ids) {
        return roleService.selectByIds(ids);
    }

    @PostMapping("selectUserIds")
    public Set<String> selectUserIds(@RequestParam("roleIds") Set<String> roleIds){
        return roleService.selectUserIds(roleIds);
    }

}
